package com.hktf.moedokilock.activity;

import android.content.res.Configuration;
import android.view.KeyEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextClock;
import android.widget.TextView;

import com.hktf.corelib.constant.KEYS;
import com.hktf.corelib.utils.CommUtils;
import com.hktf.corelib.utils.MMKVUtils;
import com.hktf.moedokilock.R;
import com.hktf.uilib.widget.SlideCloseFrameLayout;
import com.hktf.uilib.app.BaseActivity;
import com.hktf.uilib.utils.DisplayUtil;
import com.hktf.uilib.utils.ImageUtilNew;
import com.hktf.uilib.widget.NoSpaceTextView;

public class WallpaperActivity extends BaseActivity {
    private static final String TAG = "WallpaperActivity";
    private ImageView iv;
    private SlideCloseFrameLayout root;
    private android.widget.LinearLayout ll;
    private android.widget.RelativeLayout rlTime;
    private TextClock tvTime;
    private android.widget.RelativeLayout rlDate;
    private android.widget.TextView tvDate;
    private android.widget.RelativeLayout rlCustomer;
    private android.widget.TextView tv3;


    @Override
    public int getLayoutResID() {
        return R.layout.act_wallpaper;
    }

    @Override
    public void initView() {
        iv = (ImageView) findViewById(R.id.iv);
        SlideCloseFrameLayout root=findViewById(R.id.root);
        root.setOnSlideCloseListener(new SlideCloseFrameLayout.OnSlideCloseListener() {
            @Override
            public void onStartSlide() {

            }

            @Override
            public void onStopSlide(boolean isClose) {
                if (isClose) {
                    finish();
                }

            }
        });

        root = (SlideCloseFrameLayout) findViewById(R.id.root);
        ll = (LinearLayout) findViewById(R.id.ll);
        rlTime = (RelativeLayout) findViewById(R.id.rl_time);
        tvTime = findViewById(R.id.tv_time);
        rlDate = (RelativeLayout) findViewById(R.id.rl_date);
        tvDate = (TextView) findViewById(R.id.tv_date);
        rlCustomer = (RelativeLayout) findViewById(R.id.rl_customer);
        tv3 = (TextView) findViewById(R.id.tv3);
    }


    @Override
    public boolean showStatusBarAndNavBar() {
        return false;
    }

    @Override
    public void initListener() {

    }
    private int resId;

    @Override
    public void initData() {
        resId= MMKVUtils.getInteger(KEYS.LOCK_RESID,R.drawable.lock0);
        ImageUtilNew.loadImageFitXY(this,resId, DisplayUtil.getMetricsWidth(this),DisplayUtil.getMetricsHeight(this),iv);

        int FONT_COLOR = MMKVUtils.getInteger(KEYS.FONT_COLOR,com.hktf.uilib.R.color.owner_blue);
        changeColor(FONT_COLOR);
        int FONT = MMKVUtils.getInteger(KEYS.FONT, -1);
        if(FONT!=-1){
            CommUtils.setfont(this,tvTime,FONT);
        }

    }
    private void changeColor(int color){
        MMKVUtils.putInteger(KEYS.FONT_COLOR,color);
        tvTime.setTextColor(color);
        tvDate.setTextColor(color);
        tv3.setTextColor(color);
    }


    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }


    @Override
    protected void onStart() {
        super.onStart();

    }




    public void onDestroy() {
        super.onDestroy();
    }


    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }

    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }



    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {// 主要是对这个函数的复写
        // TODO Auto-generated method stub
        if ((keyCode == KeyEvent.KEYCODE_BACK)
                && (event.getAction() == KeyEvent.ACTION_DOWN)) {
//            close();
            return true;
        }
        return true;
    }
}
